package com.terrier.ui.skins
{
    import com.terrier.ui.containers.WxScrollPanel;
    import com.terrier.ui.controls.WxButton;
    import com.terrier.ui.controls.WxCheckButton;
    import com.terrier.ui.controls.WxHScrollBar;
    import com.terrier.ui.controls.WxHSlider;
    import com.terrier.ui.controls.WxLabel;
    import com.terrier.ui.controls.WxLabelButton;
    import com.terrier.ui.controls.WxList;
    import com.terrier.ui.controls.WxPanel;
    import com.terrier.ui.controls.WxTabBar;
    import com.terrier.ui.controls.WxTextArea;
    import com.terrier.ui.controls.WxTextInput;
    import com.terrier.ui.controls.WxVScrollBar;
    import com.terrier.ui.controls.WxVSlider;
    import com.terrier.ui.core.WxComponent;
    import com.terrier.ui.skins.defaults.WxButtonSkinDefault;
    import com.terrier.ui.skins.defaults.WxCheckButtonSkinDefault;
    import com.terrier.ui.skins.defaults.WxHScrollBarSkinDefault;
    import com.terrier.ui.skins.defaults.WxHSliderSkinDefault;
    import com.terrier.ui.skins.defaults.WxLabelButtonSkinDefault;
    import com.terrier.ui.skins.defaults.WxLabelSkinDefault;
    import com.terrier.ui.skins.defaults.WxListSkinDefault;
    import com.terrier.ui.skins.defaults.WxPanelSkinDefault;
    import com.terrier.ui.skins.defaults.WxScrollPanelSkinDefault;
    import com.terrier.ui.skins.defaults.WxTabBarSkinDefault;
    import com.terrier.ui.skins.defaults.WxTextInputSkinDefault;
    import com.terrier.ui.skins.defaults.WxVScrollBarSkinDefault;
    import com.terrier.ui.skins.defaults.WxVSliderSkinDefault;

    import flash.utils.Dictionary;
    import flash.utils.getQualifiedClassName;

    public class WxDefaultSkinUtility
    {
        static private var s_skinClassDict:Dictionary;

        static public function setSkin(component:WxComponent):WxComponent
        {
            initialize();
            var skinClass:Class = s_skinClassDict[getQualifiedClassName(component)];
            if (skinClass != null)
            {
                component.setSkin(new skinClass());
            }
            return component;
        }

        static public function initialize():void
        {
            if (s_skinClassDict != null)
            {
                return;
            }

            s_skinClassDict = new Dictionary();

            // 按钮
            s_skinClassDict[getQualifiedClassName(WxButton)] = WxButtonSkinDefault;
            s_skinClassDict[getQualifiedClassName(WxLabelButton)] = WxLabelButtonSkinDefault;
            s_skinClassDict[getQualifiedClassName(WxCheckButton)] = WxCheckButtonSkinDefault;
            s_skinClassDict[getQualifiedClassName(WxTabBar)] = WxTabBarSkinDefault;
            // 文本
            s_skinClassDict[getQualifiedClassName(WxLabel)] = WxLabelSkinDefault;
            s_skinClassDict[getQualifiedClassName(WxTextInput)] = WxTextInputSkinDefault;
            s_skinClassDict[getQualifiedClassName(WxTextArea)] = WxTextInputSkinDefault;
            // 滚动条
            s_skinClassDict[getQualifiedClassName(WxHScrollBar)] = WxHScrollBarSkinDefault;
            s_skinClassDict[getQualifiedClassName(WxVScrollBar)] = WxVScrollBarSkinDefault;
            // 滑块
            s_skinClassDict[getQualifiedClassName(WxHSlider)] = WxHSliderSkinDefault;
            s_skinClassDict[getQualifiedClassName(WxVSlider)] = WxVSliderSkinDefault;
            // 面板
            s_skinClassDict[getQualifiedClassName(WxPanel)] = WxPanelSkinDefault;
            s_skinClassDict[getQualifiedClassName(WxScrollPanel)] = WxScrollPanelSkinDefault;
            s_skinClassDict[getQualifiedClassName(WxList)] = WxListSkinDefault;
        }
    }
}
